<?php
namespace app\admin\controller;
use think\Controller;

class Login extends Controller
{
    /* 登录页面 */
    public function index()
    {
        return view();
    }

    /* 验证登录方法 */
    public function checkLogin()
    {
        $admin_id = 1;
        session('admin_login', 1);
        session('admin_id', $admin_id);
        session('admin_name', 'admin');
        //记录权限
        session('admin_jurisdiction_' . $admin_id, ['index_index', 'product_index', 'product_add', ]);
        exit(json_encode(array('state' => 200, 'data' => input('post.'))));
    }

    /* 退出登录 */
    public function logout() {
        session('admin_jurisdiction_' . session('admin_id'), null);
        session('admin_login', null);
        session('admin_id', null);
        session('admin_name', null);
        $this->success('退出登陆', 'login/index');
    }

    public  function test() {
        return view();
    }
}
